﻿<UserControl x:Class="XERP.Client.WPF.MainMenu.Views.MainMenuView"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
              xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             >
    <UserControl.Resources>
        <HierarchicalDataTemplate x:Key="MenuTemplate" ItemsSource="{Binding Children}" >
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding Path=DBImageAsImage}">   
                </Image>
                <TextBlock Text="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="35"></RowDefinition>
            <RowDefinition Height="536*"></RowDefinition>
            <RowDefinition Height="28"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="400*"></ColumnDefinition>
            <ColumnDefinition Width="400*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Stretch">
            <TextBlock Grid.Column="1" Text="XERP Main Menu:"
               FontSize="16"
               Margin="0,0,0,0" Height="19"></TextBlock>
            
        </StackPanel>
        <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Stretch">
            <TextBlock Grid.Column="1" Text="Current Company: "
               FontSize="12"
               Margin="0,0,0,0" Height="22"></TextBlock>
            <TextBlock Grid.Column="1" Text="{Binding GlobalCompanyID}"
               FontSize="12"
               Margin="0,0,20,0" Height="22"></TextBlock>
        </StackPanel>
        <Menu IsMainMenu="True" Margin="10,2,2,2" Width="180" HorizontalAlignment="Left">
            <MenuItem Header="_Tools" />
            <MenuItem Header="_Actions" />
            <MenuItem Header="_Help" />
        </Menu>
        
        <TreeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"
                        ItemTemplate="{StaticResource MenuTemplate}"  
                      ItemsSource="{Binding TreeNestedMenuItemList}" Grid.Row="1"
                  SelectedItemChanged="tv_SelectedItemChanged" 
                  >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseUp">
                    <ei:CallMethodAction
                        TargetObject="{Binding}"
                        MethodName="TreeMenuItemSelectedCommand"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TreeView>
        
        <GridSplitter Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" Width="4" Background="Yellow"/>

        <ListBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"
           ItemsSource="{Binding DisplayedMenuItemList}"
            SelectionMode="Single"
            SelectedItem="{Binding SelectedDisplayedMenuItemList}">
            <ListBox.ItemTemplate>
                <DataTemplate  >
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding DBImageAsImage}"></Image>
                        <TextBlock Text="{Binding Path=Description, Mode=TwoWay}" Margin="5"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseUp">
                    <ei:CallMethodAction
                        TargetObject="{Binding}"
                        MethodName="MenuItemSelectedCommand"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </ListBox>
    </Grid>
</UserControl>
